package org.example.hw.dto.user;

import java.util.Date;

import javax.validation.constraints.Past;

import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.example.hw.dto.AbstractEditDto;
import org.example.hw.model.User;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.format.annotation.DateTimeFormat;

public class EditUserDto extends AbstractEditDto {

	private String firstname;

	private String lastname;

	// TODO: google how to user html5 tag attribute with spring tags, other then javascript
	@Email
	@NotBlank
	private String email;

	@DateTimeFormat
	@Past
	private Date dateOfBirth;

	public EditUserDto() {

	}

	public EditUserDto(User user) {
		this.firstname = user.getFirstname();
		this.lastname = user.getLastname();
		this.email = user.getEmail();
		this.dateOfBirth = user.getDateOfBirth();
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE).
				append("firstname", firstname).
				append("lastname", lastname).
				append("email", email).
				append("dateOfBirth", dateOfBirth).
				append(super.toString()).
				toString();
	}

}
